package com.ngc.mall.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ngc.mall.common.configure.response.ResponseResult;
import com.ngc.mall.domain.CategoryDomain;
import com.ngc.mall.service.ICategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController {
    @Resource
    private ICategoryService iCategoryService;
    /**
     * 获取所有商品分类
     * @return
     */
    @GetMapping("/list")
    public ResponseResult<List<CategoryDomain>> selectAll(){
        Wrapper wrapper= Wrappers.<CategoryDomain>lambdaQuery().eq(CategoryDomain::getIsEnabled,true);
        return ResponseResult.success(iCategoryService.list(wrapper));
    }


}
